3.2.37 \(\int \tanh (c+d x) (a+b \tanh ^2(c+d x)) \, dx\) [137]

Optimal. Leaf size=31 \[ \frac {(a+b) \log (\cosh (c+d x))}{d}-\frac {b \tanh ^2(c+d x)}{2 d} \]

[Out]

(a+b)*ln(cosh(d*x+c))/d-1/2*b*tanh(d*x+c)^2/d

________________________________________________________________________________________

Rubi [A]
time = 0.02, antiderivative size = 31, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, integrand size = 19, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.105, Rules used = {3712, 3556} \begin {gather*} \frac {(a+b) \log (\cosh (c+d x))}{d}-\frac {b \tanh ^2(c+d x)}{2 d} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[Tanh[c + d*x]*(a + b*Tanh[c + d*x]^2),x]

[Out]

((a + b)*Log[Cosh[c + d*x]])/d - (b*Tanh[c + d*x]^2)/(2*d)

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3712

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Simp
[C*((a + b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1))), x] + Dist[A - C, Int[(a + b*Tan[e + f*x])^m, x], x] /; FreeQ[
{a, b, e, f, A, C, m}, x] && NeQ[A*b^2 + a^2*C, 0] &&  !LeQ[m, -1]

Rubi steps

\begin {align*} \int \tanh (c+d x) \left (a+b \tanh ^2(c+d x)\right ) \, dx &=-\frac {b \tanh ^2(c+d x)}{2 d}-(-a-b) \int \tanh (c+d x) \, dx\\ &=\frac {(a+b) \log (\cosh (c+d x))}{d}-\frac {b \tanh ^2(c+d x)}{2 d}\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.02, size = 41, normalized size = 1.32 \begin {gather*} \frac {a \log (\cosh (c+d x))}{d}+\frac {b \log (\cosh (c+d x))}{d}-\frac {b \tanh ^2(c+d x)}{2 d} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[Tanh[c + d*x]*(a + b*Tanh[c + d*x]^2),x]

[Out]

(a*Log[Cosh[c + d*x]])/d + (b*Log[Cosh[c + d*x]])/d - (b*Tanh[c + d*x]^2)/(2*d)

________________________________________________________________________________________

Maple [A]
time = 0.37, size = 49, normalized size = 1.58

method result size
derivativedivides \(\frac {-\frac {b \left (\tanh ^{2}\left (d x +c \right )\right )}{2}-\frac {\left (a +b \right ) \ln \left (\tanh \left (d x +c \right )-1\right )}{2}+\frac {\left (-a -b \right ) \ln \left (1+\tanh \left (d x +c \right )\right )}{2}}{d}\) \(49\)
default \(\frac {-\frac {b \left (\tanh ^{2}\left (d x +c \right )\right )}{2}-\frac {\left (a +b \right ) \ln \left (\tanh \left (d x +c \right )-1\right )}{2}+\frac {\left (-a -b \right ) \ln \left (1+\tanh \left (d x +c \right )\right )}{2}}{d}\) \(49\)
risch \(-a x -b x -\frac {2 a c}{d}-\frac {2 b c}{d}+\frac {2 b \,{\mathrm e}^{2 d x +2 c}}{d \left (1+{\mathrm e}^{2 d x +2 c}\right )^{2}}+\frac {\ln \left (1+{\mathrm e}^{2 d x +2 c}\right ) a}{d}+\frac {\ln \left (1+{\mathrm e}^{2 d x +2 c}\right ) b}{d}\) \(86\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(tanh(d*x+c)*(a+b*tanh(d*x+c)^2),x,method=_RETURNVERBOSE)

[Out]

1/d*(-1/2*b*tanh(d*x+c)^2-1/2*(a+b)*ln(tanh(d*x+c)-1)+1/2*(-a-b)*ln(1+tanh(d*x+c)))

________________________________________________________________________________________

Maxima [B] Leaf count of result is larger than twice the leaf count of optimal. 76 vs. \(2 (29) = 58\).
time = 0.51, size = 76, normalized size = 2.45 \begin {gather*} b {\left (x + \frac {c}{d} + \frac {\log \left (e^{\left (-2 \, d x - 2 \, c\right )} + 1\right )}{d} + \frac {2 \, e^{\left (-2 \, d x - 2 \, c\right )}}{d {\left (2 \, e^{\left (-2 \, d x - 2 \, c\right )} + e^{\left (-4 \, d x - 4 \, c\right )} + 1\right )}}\right )} + \frac {a \log \left (\cosh \left (d x + c\right )\right )}{d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tanh(d*x+c)*(a+b*tanh(d*x+c)^2),x, algorithm="maxima")

[Out]

b*(x + c/d + log(e^(-2*d*x - 2*c) + 1)/d + 2*e^(-2*d*x - 2*c)/(d*(2*e^(-2*d*x - 2*c) + e^(-4*d*x - 4*c) + 1)))
 + a*log(cosh(d*x + c))/d

________________________________________________________________________________________

Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 399 vs. \(2 (29) = 58\).
time = 0.37, size = 399, normalized size = 12.87 \begin {gather*} -\frac {{\left (a + b\right )} d x \cosh \left (d x + c\right )^{4} + 4 \, {\left (a + b\right )} d x \cosh \left (d x + c\right ) \sinh \left (d x + c\right )^{3} + {\left (a + b\right )} d x \sinh \left (d x + c\right )^{4} + {\left (a + b\right )} d x + 2 \, {\left ({\left (a + b\right )} d x - b\right )} \cosh \left (d x + c\right )^{2} + 2 \, {\left (3 \, {\left (a + b\right )} d x \cosh \left (d x + c\right )^{2} + {\left (a + b\right )} d x - b\right )} \sinh \left (d x + c\right )^{2} - {\left ({\left (a + b\right )} \cosh \left (d x + c\right )^{4} + 4 \, {\left (a + b\right )} \cosh \left (d x + c\right ) \sinh \left (d x + c\right )^{3} + {\left (a + b\right )} \sinh \left (d x + c\right )^{4} + 2 \, {\left (a + b\right )} \cosh \left (d x + c\right )^{2} + 2 \, {\left (3 \, {\left (a + b\right )} \cosh \left (d x + c\right )^{2} + a + b\right )} \sinh \left (d x + c\right )^{2} + 4 \, {\left ({\left (a + b\right )} \cosh \left (d x + c\right )^{3} + {\left (a + b\right )} \cosh \left (d x + c\right )\right )} \sinh \left (d x + c\right ) + a + b\right )} \log \left (\frac {2 \, \cosh \left (d x + c\right )}{\cosh \left (d x + c\right ) - \sinh \left (d x + c\right )}\right ) + 4 \, {\left ({\left (a + b\right )} d x \cosh \left (d x + c\right )^{3} + {\left ({\left (a + b\right )} d x - b\right )} \cosh \left (d x + c\right )\right )} \sinh \left (d x + c\right )}{d \cosh \left (d x + c\right )^{4} + 4 \, d \cosh \left (d x + c\right ) \sinh \left (d x + c\right )^{3} + d \sinh \left (d x + c\right )^{4} + 2 \, d \cosh \left (d x + c\right )^{2} + 2 \, {\left (3 \, d \cosh \left (d x + c\right )^{2} + d\right )} \sinh \left (d x + c\right )^{2} + 4 \, {\left (d \cosh \left (d x + c\right )^{3} + d \cosh \left (d x + c\right )\right )} \sinh \left (d x + c\right ) + d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tanh(d*x+c)*(a+b*tanh(d*x+c)^2),x, algorithm="fricas")

[Out]

-((a + b)*d*x*cosh(d*x + c)^4 + 4*(a + b)*d*x*cosh(d*x + c)*sinh(d*x + c)^3 + (a + b)*d*x*sinh(d*x + c)^4 + (a
 + b)*d*x + 2*((a + b)*d*x - b)*cosh(d*x + c)^2 + 2*(3*(a + b)*d*x*cosh(d*x + c)^2 + (a + b)*d*x - b)*sinh(d*x
 + c)^2 - ((a + b)*cosh(d*x + c)^4 + 4*(a + b)*cosh(d*x + c)*sinh(d*x + c)^3 + (a + b)*sinh(d*x + c)^4 + 2*(a
+ b)*cosh(d*x + c)^2 + 2*(3*(a + b)*cosh(d*x + c)^2 + a + b)*sinh(d*x + c)^2 + 4*((a + b)*cosh(d*x + c)^3 + (a
 + b)*cosh(d*x + c))*sinh(d*x + c) + a + b)*log(2*cosh(d*x + c)/(cosh(d*x + c) - sinh(d*x + c))) + 4*((a + b)*
d*x*cosh(d*x + c)^3 + ((a + b)*d*x - b)*cosh(d*x + c))*sinh(d*x + c))/(d*cosh(d*x + c)^4 + 4*d*cosh(d*x + c)*s
inh(d*x + c)^3 + d*sinh(d*x + c)^4 + 2*d*cosh(d*x + c)^2 + 2*(3*d*cosh(d*x + c)^2 + d)*sinh(d*x + c)^2 + 4*(d*
cosh(d*x + c)^3 + d*cosh(d*x + c))*sinh(d*x + c) + d)

________________________________________________________________________________________

Sympy [B] Leaf count of result is larger than twice the leaf count of optimal. 60 vs. \(2 (26) = 52\).
time = 0.08, size = 60, normalized size = 1.94 \begin {gather*} \begin {cases} a x - \frac {a \log {\left (\tanh {\left (c + d x \right )} + 1 \right )}}{d} + b x - \frac {b \log {\left (\tanh {\left (c + d x \right )} + 1 \right )}}{d} - \frac {b \tanh ^{2}{\left (c + d x \right )}}{2 d} & \text {for}\: d \neq 0 \\x \left (a + b \tanh ^{2}{\left (c \right )}\right ) \tanh {\left (c \right )} & \text {otherwise} \end {cases} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tanh(d*x+c)*(a+b*tanh(d*x+c)**2),x)

[Out]

Piecewise((a*x - a*log(tanh(c + d*x) + 1)/d + b*x - b*log(tanh(c + d*x) + 1)/d - b*tanh(c + d*x)**2/(2*d), Ne(
d, 0)), (x*(a + b*tanh(c)**2)*tanh(c), True))

________________________________________________________________________________________

Giac [A]
time = 0.43, size = 57, normalized size = 1.84 \begin {gather*} -\frac {{\left (d x + c\right )} {\left (a + b\right )} - {\left (a + b\right )} \log \left (e^{\left (2 \, d x + 2 \, c\right )} + 1\right ) - \frac {2 \, b e^{\left (2 \, d x + 2 \, c\right )}}{{\left (e^{\left (2 \, d x + 2 \, c\right )} + 1\right )}^{2}}}{d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tanh(d*x+c)*(a+b*tanh(d*x+c)^2),x, algorithm="giac")

[Out]

-((d*x + c)*(a + b) - (a + b)*log(e^(2*d*x + 2*c) + 1) - 2*b*e^(2*d*x + 2*c)/(e^(2*d*x + 2*c) + 1)^2)/d

________________________________________________________________________________________

Mupad [B]
time = 1.17, size = 37, normalized size = 1.19 \begin {gather*} x\,\left (a+b\right )-\frac {b\,{\mathrm {tanh}\left (c+d\,x\right )}^2}{2\,d}-\frac {\ln \left (\mathrm {tanh}\left (c+d\,x\right )+1\right )\,\left (a+b\right )}{d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(tanh(c + d*x)*(a + b*tanh(c + d*x)^2),x)

[Out]

x*(a + b) - (b*tanh(c + d*x)^2)/(2*d) - (log(tanh(c + d*x) + 1)*(a + b))/d

________________________________________________________________________________________